package com.bxmdm.ragdemo.config;

import java.nio.charset.StandardCharsets;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description: 过滤器
 * @Author: jay
 * @Date: 2021/4/7 13:30
 * @Version: 1.0
 */
@Configuration
public class SystemConfigurer implements WebMvcConfigurer {


	@Bean
	public HttpMessageConverter<String> responseBodyConverter() {
		return new StringHttpMessageConverter(StandardCharsets.UTF_8);
	}

	@Override
	public void addCorsMappings(CorsRegistry registry) {
		registry
				.addMapping("/**")
				.allowedMethods("*")
				.allowedOriginPatterns("*")
				.allowedHeaders("*")
				.allowCredentials(true);
	}
}
